package com.example.online_order.mapper;

import com.example.online_order.pojo.AdminAccount;
import com.example.online_order.pojo.Shoppingcar;
import com.example.online_order.pojo.Shoucanglan;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ShoucanglanMapper {
    @Select("select * from shoucanglan")
    public List<Shoucanglan> getAllS();

    @Select("select * from shoucanglan where id = #{id}")
    public Shoucanglan getSById(Integer id);

    @Insert("insert into shoucanglan (id,goodsId,userName,userId,goodsName) values (null,#{goodsId},#{userName},#{userId},#{goodsName})")
    public Integer addToS(Shoucanglan s);

    @Delete("delete from shoucanglan where id =#{id}")
    public Integer deleteS(Integer id);

    @Update("update shoucanglan set id= #{id}, goodsId= #{goodsId}, userName= #{userName}, userId= #{userId},goodsName=#{goodsName} where id = #{id}")
    public Integer updateS(Shoucanglan s);
    @Select("select * from shoucanglan where goodsName= #{goodsName}")
    public Shoucanglan findSByGoodsname(String goodsname);
    @Select("select * from shoucanglan where goodsName like '%${goodsName}%' ")
    public List <Shoucanglan> findSLikeGoodsname(String goodsname);

    @Select("select * from shoucanglan where userId = #{userId} and goodsId= #{goodsId}")
    Shoucanglan getSByGoodsId(Integer userId,Integer goodsId);

    @Select("select * from shoucanglan where userName = #{userName}")
    public List<Shoucanglan> getSByUsername(String userName);
}
